import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:s_mankey/config/net/smonkey_api.dart';
import 'package:s_mankey/config/net/smonkey_ui_api.dart';
import 'package:s_mankey/model/audio_detail_model.dart';
import 'package:s_mankey/model/exp_waller_model.dart';
import 'package:s_mankey/model/favorites_model.dart';
import 'package:s_mankey/model/banner_model.dart';
import 'package:s_mankey/model/enterprise_list_model.dart';
import 'package:s_mankey/model/home_article_model.dart';
import 'package:s_mankey/model/home_audio_model.dart';
import 'package:s_mankey/model/home_banner_model.dart';
import 'package:s_mankey/model/search_article_model.dart';
import 'package:s_mankey/model/search_enterprise_model.dart';
import 'package:s_mankey/model/video_list_model.dart';
import 'package:s_mankey/model/waller_model.dart';
import 'package:s_mankey/view_model/home_vmodel.dart';


class SmonkeysRepository {


  // 登录
  static Future fetchPaswLogin({Map<String, dynamic> options}) async {
    var response = await http.post('login_password', data: options);
    return response.data;
  }

  // 轮播测试
  static Future fetchHomeBanner1({String abridge='banner', String city='CM', String lang='s'}) async {
    var response = await http1.get('advert/list', queryParameters: {'abridge': abridge, 'city': city, "lang": lang});
    return response.data;
  }

  // 轮播
  static Future fetchHomeBanner({String abridge='banner', String city='CM', String lang='s'}) async {
    var response = await http.get('advert/list', queryParameters: {'abridge': abridge, 'city': city, "lang": lang});
    return response.data;
  }

  // 加载课程推荐
  static Future fetchRecommendSource({String city, String lang}) async {
    var response = await http.get('recommend_course', queryParameters: {'city': city, 'lang': lang});
    return response.data;
  }

  // 加载文章列表
  static Future fetchHomeArticle() async {
    var response = await http.get('article/list', queryParameters: {'is_position': 1});
    return response.data[0];
  }

  // 加载音频课程
  static Future fetchHomenAudio() async {
    var response = await http.get('audio_courses/recommend');
    return response.data[0];
  }

  // 加载首页诚信圈推荐
  static Future fetchHomeIntegrityHot({String font}) async {
    var response = await http.get('integrity/recommend');
    return response.data;
  }

  // 加载首页课程分类
  static Future fetchHomeCourse({String city, String lang, String keyword}) async {
    var response = await http.get('get_course',queryParameters: {'city': city, 'lang': lang, 'keyword': keyword});
    return response.data;
  }

  // 加载音频详情分类
  static Future fetchAudioDetail({int vid}) async {
    var response = await http.get('audio_courses/intro',queryParameters: {'vid': vid});
    return AudioDetailModel.fromJson(response.data);
  }

  // 加载音频列表数据
  static Future fetchAudioList() async {
    var response = await http.get('audio_courses/list');
    return response.data;
  }

  /// **************** 我的页面数据 **************** ///
  // 用户头像
  static Future fetchMyInfoData() async {
    var response = await http.get('member/home');
    return response.data;
  }

  // 用户粉丝数量
  static Future fetchMyFansNum() async {
    var response = await http.get('has_notify');
    return response.data;
  }

  // 查看用户详情资料
  static Future fetchMyFirstDetail() async {
    var response = await http.get('member/first_detail');
    return response.data;
  }

  // 编辑时查看用户详情资料
  static Future fetchMyEditorDetail() async {
    var response = await http.get('member/detail');
    return response.data;
  }

  // 编辑时保存用户资料
  static  fetchMyEditorSave({Map<String,dynamic> datas}) {
    var response = http.put('member/edit',data: datas);
    return response;
  }

  // 学习里程盛点记录
  static Future fetchMyWallet() async {
    var response = await http.get('miles_wallet');
    return response.data;
  }

  // 我的钱包经验
  static Future fetchMyExpWallet() async {
    var response = await http.get('exp_wallet');
    return response.data;
  }

  // 选择城市列表
  static Future fetchMyChooseCity() async {
    var response = await http.get('city/api_list');
    return response.data;
  }

  // 课程邀请记录
  static Future fetchMyInvitationHistory() async {
    var response = await http.get('course/invitation_history');
    return response.data;
  }

  // 邀请课程搜索记录
  static Future fetchMySearchChooseCourse({Map<String,dynamic> options}) async {
    var response = await http.get('course/choise_course',queryParameters: options);
    return response.data;
  }

  // 邀请课程确认详情
  static Future fetchMyInvitationCourseDetail({Map<String,dynamic> options}) async {
    var response = await http.get('course/choise_course_detail',queryParameters: options);
    return response.data;
  }

  // 邀请课程查看最大可用盛点
  static Future fetchMyInviteMiles({Map<String,dynamic> options}) async {
    var response = await http.get('member/look_miles',queryParameters: options);
    return response.data;
  }

  // 确认邀请
  static Future fetchConfirmInvite({Map<String,dynamic> options}) async {
    var response = await http.get('course/invitation_courses',queryParameters: options);
    return response.data;
  }

  // 播放视频
  static Future fetchVideosDetail({Map<String,dynamic> options}) async {
    var response = await http.get('video/find',queryParameters: options);
    return response.data;
  }

  // 系统通知列表
  static Future fetchNotifyList({Map<String,dynamic> options}) async {
    var response = await http.get('notify_list',queryParameters: options);
    return response.data;
  }

  // 系统通知消息详情
  static Future fetchNotifyDetail({Map<String,dynamic> options}) async {
    var response = await http.get('get_notify',queryParameters: options);
    return response.data;
  }

  // 课程邀请详情
  static Future fetchCourseInvitationDetail({String id}) async {
    var response = await http.get('course/invitation_detail/'+ id);
    return response.data;
  }

  // 学员认证
  static Future fetchIsIdentify() async {
    var response = await http.post('is_identify');
    return response.data;
  }

  // 平台联系方式
  static Future fetchTellMe() async {
    var response = await http.get('config/app_json/1');
    return response.data;
  }

  // 确认密码
  static Future fetchConfirmPasw({@required Map<String, dynamic> options}) async {
    var response = await http.post('member/check_password', data: options);
    return response;
  }

  // 我的视频列表
  static Future fetchVideoList() async {
    var response = await http.get('video/list');
    return response.data.map<VideoListModel>((item) => VideoListModel.fromJson(item)).toList();
  }


  // 诚信商圈列表
  static Future fetchEnterpriseList() async {
    var response = await http.get('integrity/list',);
    return response.data;
  }

  // 点藏/收藏列表
  static Future fetchFavoritesList() async {
    var response = await http.get('audio_courses/collectandlike',);
    return FavoritesListModel.fromJson(response.data);
  }

  // 搜索企业
  static Future fetchSearchEnterpeise({Map<String, dynamic> options}) async {
    var response = await http.get('integrity/load?',queryParameters: options);
    return response.data;
  }

}
